package com.ikas.ai.server.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author hubowei
 * @email hu.bowei@ikasinfo.com
 * @date 2023-8-29 15:13:36
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private UserInterceptor userInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册自己的拦截器并设置拦截的请求路径
        registry.addInterceptor(userInterceptor).addPathPatterns("/**")
                // 登录接口不做校验
                .excludePathPatterns("/error")
                .excludePathPatterns("/captcha")
                .excludePathPatterns("/login/**")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/logout")
                .excludePathPatterns("/system/info")
                .excludePathPatterns("/system/test/**")
                .excludePathPatterns("/static/**")
                .excludePathPatterns("/mete/send")
                .excludePathPatterns("/init/**")
                .excludePathPatterns("/api/user/**");
    }
}
